package com.yxw.springmvc.userBehavior.service.impl;

import com.yxw.springmvc.userBehavior.convert.BasicRoleConvert;
import com.yxw.springmvc.userBehavior.mapper.BasicRoleMapper;
import com.yxw.springmvc.userBehavior.model.BasicRole;
import com.yxw.springmvc.userBehavior.request.BasicRoleAddRequest;
import com.yxw.springmvc.userBehavior.service.BasicRoleManageService;
import com.yxw.springmvc.userBehavior.util.CollectionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by hp on 2016/9/26.
 */
@Service
@Slf4j
public class BasicRoleManageServiceImpl implements BasicRoleManageService {

    @Resource
    private BasicRoleConvert basicRoleConvert;

    @Resource
    private BasicRoleMapper basicRoleMapper;

    @Override
    public BasicRole add(BasicRoleAddRequest request) {
        if(CollectionUtils.isEmpty(request)){
            return null;
        }
        BasicRole role = basicRoleConvert.convert(request);
        basicRoleMapper.insert(role);
        return role;
    }
}
